FROM python:3.11-slim

WORKDIR /app

# 安装系统依赖
RUN echo 'deb http://mirrors.aliyun.com/debian/ bookworm main contrib non-free\ndeb http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free\ndeb http://mirrors.aliyun.com/debian-security bookworm-security main contrib non-free' > /etc/apt/sources.list \
    && apt-get update && apt-get install -y --fix-missing \
    libxml2-dev \
    libxslt-dev \
    && rm -rf /var/lib/apt/lists/*

# 复制requirements并安装依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 复制应用代码
COPY . .

# 创建必要的目录
RUN mkdir -p src/template src/render public

# 暴露端口
EXPOSE 8000

# 启动命令
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]